﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Data;
using Bymed.SpineScan.DataModel;
using Bymed.SpineScan.Service.Validation;

namespace Bymed.SpineScan.WPF.ValidationRules
{
    public class AttendingDoctorNameValidationRule : ValidationRule
    {
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            var doctor = (value as BindingGroup).Items[0] as AttendingDoctor;
            var doctorValidator = new AttendingDoctorValidator();

            if (!doctorValidator.CheckNameLength(doctor))
            {
                return new ValidationResult(false, doctorValidator.GetError(AttendingDoctorValidator.NameErrorKey));
            }

            return ValidationResult.ValidResult;
        }
    }
}
